Skip to content

mcpx: correlate -32042 retries with the suspended call (#2897) - #8995

Closed
dezren39 wants to merge 1 commit into
mainfrom
fix/mcpx-2897-32042-request-state
Closed

dezren39 wants to merge 1 commit into
mainfrom
fix/mcpx-2897-32042-request-state

Conversation

@dezren39

@dezren39 dezren39 commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Fixes #2897.

Problem

urlRequiredResponse emitted -32042 with only data.elicitations; a host retry carried no token, so beginAsk called Ask.Begin and ran the upstream operation a second time while the original suspended call was still alive.

Change

  • -32042 data now carries requestState: the existing signed token (bound to method + param digest, expiring) naming the suspended call. Both emit sites (entry trigger and in-loop ErrNoPush trigger) mint it.
  • resumeOf also reads the token from _meta["mcpx/requestState"], because a 2025-11-25 request schema rejects a top-level requestState. The 2026 requestState field still works.
  • mcpx's own client echoes the token on its single bounded retry (plain and legacy-task paths).

Behaviour

  • Retry after out-of-band completion with the token: resumes the original call, answered from its outcome; upstream operation executes exactly once.
  • Retry before completion with the token: stays on the same call and gets -32042 again with a fresh token. No duplicate execution.
  • Retry without a token (host ignored the field): unchanged, starts a new call. Not preventable server-side without merging distinct concurrent calls.
  • mcpx: Phase 3 of #2077 — produce -32042 where it is true, register truth-up (ELI-04/09/12), and #1935 closure #2080 preserved: broker keeps pending questions; no Abandon.

Tests

  • TestURLRequiredWhenNoChannelToAskOn: exactly-once across an early retry and a post-completion retry (began == 1).
  • TestURLElicitationRetryCarriesRequestState: client echoes the token.
  • Existing mcpclient, mcpserver and daemon -32042 tests pass; -race -shuffle=on -count=5 on the changed tests.

Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

-32042 now carries data.requestState, a signed token bound to the request
and the suspended call. A host echoing it (_meta["mcpx/requestState"] or
requestState) resumes the original call instead of Begin-ing a second
upstream invocation; a retry before completion gets -32042 again with a
fresh token. mcpx's own client echoes the token on its single retry.
Retries without a token keep the old behaviour.
@dezren39
dezren39 requested a review from a team as a code owner November 12, 2026 19:23
@coderabbitai

coderabbitai Bot commented Nov 12, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 45 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6a070955-30f5-4f22-99f5-937c1791cb43
Commits

Reviewing files that changed from the base of the PR and between 3273254 and 28b20d3.

Files selected for processing: 6

  • pkgs/mcpx/internal/mcpclient/client.go
  • pkgs/mcpx/internal/mcpclient/tasks.go
  • pkgs/mcpx/internal/mcpclient/url_elicitation_32042_test.go
  • pkgs/mcpx/internal/mcpserver/ask.go
  • pkgs/mcpx/internal/mcpserver/url_required.go
  • pkgs/mcpx/internal/mcpserver/url_required_test.go
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-12T19:27:14.350456Z 28b20d3 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 28b20d3259

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

// below (#1556 Codex review).
if retry, rerr := c.urlElicitationRetry(ctx, name, err); retry {
raw, err = c.callToolAsLegacyTask(ctx, name, args)
raw, err = c.callToolAsLegacyTask(ctx, name, args, requestStateOf(err))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve the task relay token across the correlated retry

For a legacy task-required tool that returns -32042 with a requestState, callers requesting progress can lose notifications after the retry. The first callToolAsLegacyTask invocation unregisters its relay through defer done(), and this second invocation registers a newly generated progress token. Since the retry now resumes the original operation rather than starting another one, progress emitted against the original token is rejected by acceptProgress in relay.go. Keep the relay registration and progress token alive across the bounded retry, as the plain-call path does.

Useful? React with 👍 / 👎.

@dezren39

Copy link
Copy Markdown
Member Author

Closing as a duplicate of #8999, the canonical PR bound to queue task 8931. The one unique piece here (the legacy-task retry in tasks.go) is recorded as a salvage note on #8999. Branch fix/mcpx-2897-32042-request-state is left in place.

@dezren39 dezren39 closed this Nov 12, 2026
@dezren39
dezren39 deleted the fix/mcpx-2897-32042-request-state branch November 14, 2026 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mcpx: correlate -32042 retries with the suspended call (no double execution)

1 participant